/**
 * 
 */
package com.dream.house.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.com.servyou.base.exception.DAOException;

import com.dream.house.dao.BuyDAO;
import com.dream.house.dao.base.HouseBaseDAO;
import com.dream.house.entity.BuyDTO;

/**
 * 住房/租房申请管理
 * @author ahk
 * @since 1.0
 */
public class BuyDAOImpl extends HouseBaseDAO implements BuyDAO {

	/* (non-Javadoc)
	 * @see cn.com.servyou.base.dao.BaseDAO#getEntityName()
	 */
	@Override
	public String getEntityName() {
		return BuyDTO.class.getCanonicalName();
	}

	@Override
	public boolean saveBuy(BuyDTO dto) throws DAOException {
		
		return createEntity("saveBuy", dto);
	}

	@Override
	public boolean updateBuy(BuyDTO dto) throws DAOException {
		
		return updateEntity("updateBuy", dto);
	}

	@Override
	public boolean removeBuy(String id) throws DAOException {
		
		return removeEntity("removeBuy", id);
	}

	@Override
	public BuyDTO getBuy(String id) throws DAOException {
		
		return (BuyDTO)getEntity("getBuy",id);
	}

	@SuppressWarnings("unchecked")
	public List<BuyDTO> getBuysByRoom(String room_id) throws DAOException{
		return (List<BuyDTO>)getEntitys("getBuysByRoom",room_id);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<BuyDTO> findBuys(BuyDTO dto) throws DAOException {
		
		return (List<BuyDTO>)getEntitys("findBuys",dto);
	}

	@Override
	public boolean updateBuyStatus(String id, String status)
			throws DAOException {
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("id", id);
		map.put("status", status);
		
		return updateEntity("updateBuyStatus", status);
	}
	
}
